﻿namespace CodeParser.Tokens
{
    public class StringBlock
        : TokenParser
    {

        public StringBlock(TokenType type, string begin, string end)
            : base(type)
        {
            Begin = begin;
            End = end;
        }

        public override Token GetTokenAt(string source, int index)
        {
            if (StringUtils.Matches(source, index, Begin))
            {
                var keywordIndex = 0;
                var end = End;
                var sourceLength = source.Length;
                for (var i = index; i < sourceLength; i++)
                {
                    if (StringUtils.Matches(source, i, end))
                    {
                        return new Token()
                            {
                                Index = index,
                                Type = Type.Value,
                                Value = source.Substring(index, i - index + end.Length)
                            };
                    }
                }
            }
            return null;
        }


        public string Begin;
        public string End;



    }
}
